package com.cr.mrapp.service.impl;

import com.cr.mrapp.dao.StaffDao;
import com.cr.mrapp.entity.Staff;
import com.cr.mrapp.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StaffServiceImpl implements StaffService {

    @Autowired
    private StaffDao staffDao;

    @Override
    public int addStaff(Staff body) {
        return staffDao.insert(body);
    }

    @Override
    public List<Object> findByPage(int page, int limit, String staffName) {
        return staffDao.selectByPage((page-1)*limit,limit,staffName);
    }

    @Override
    public int findCount() {
        return staffDao.selectCount();
    }

    @Override
    public int deleteById(int staffId) {
        return staffDao.deleteByPrimaryKey(staffId);
    }

    @Override
    public Staff findById(int id) {
        return staffDao.selectByPrimaryKey(id);
    }

    @Override
    public List<Object> findByStoreId(int storeId) {
        return staffDao.selectByStoreId(storeId);
    }
}

